﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
using Konst3d.Efficiency.Suite;

namespace Konst3d.Efficiency.Suite.SparsedBinary
{
    internal interface IMilestoneStorage
    {
        void UpdateDate         (int id, DateTime date);
        void UpdateTitle        (int id, string title);
        void UpdateDescription  (int id, string description);
    }

    internal class Milestone: IMilestone
    {
        #region IMilestone Members

        public DateTime Date
        {
            get
            {
                return _date;
            }
			set
			{
				_storage.UpdateDate(_id, value);
				_date = value;
			}
        }

        public string Title
        {
            get
            {
                return _title;
            }
            set
            {
                _storage.UpdateTitle(_id, value);
                _title = value;
            }
        }

        public string Description
        {
            get
            {
                return _description;
            }
            set
            {
                _storage.UpdateDescription(_id, value);
                _description = value;
            }
        }

        public int ID
        {
            get
            {
                return _id;
            }
        }

        #endregion

        #region Constructor

        public Milestone(IMilestoneStorage storage, int id, DateTime date, string title, string description)
        {
            Contract.Requires(storage != null);

            _storage = storage;
            _date = date;
            _id = id;
            _title = title;
            _description = description;
        }

        #endregion // Constructor

        #region Fields

        private IMilestoneStorage _storage;
        private DateTime _date;
        private int _id;
        private string _title;
        private string _description;

        #endregion // Fields
    }
}
